Use case: I3C target transmit in polling, interrupt and DMA mode

This use case shows how an I3C target transmits data in polling, interrupt, or DMA mode.

Sequence diagram

    @startuml
    participant "Application" as App
    participant "I3C" as I3C

    App -> I3C: HAL_I3C_Tgt_Transmit() / HAL_I3C_Tgt_Transmit_IT() / HAL_I3C_Tgt_Transmit_DMA()
    @enduml

Code snippet

HAL1

HAL2

I3C_HandleTypeDef hi3c;
I3C_XferTypeDef xferData;
uint32_t ctrlBuffer[2] = {0};
uint32_t status_buffer[2] = {0};

xferData.CtrlBuf = ctrlBuffer;
xferData.StatusBuf = status_buffer;

// Prepare data to transmit
uint8_t tx_buf[8] = {0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80};
xferData.TxBuf.pData = tx_buf;
xferData.TxBuf.size = 8;

// Transmit data in target mode
HAL_StatusTypeDef status = HAL_I3C_Tgt_Transmit(&hi3c, &xferData, 5000);
/* Interrupt and DMA modes: the operation is asynchronous and completion
will be notified to the user via HAL_I3C_TgtTxCpltCallback */
HAL_I3C_Tgt_Transmit_IT(&hi3c, &xferData);
HAL_I3C_Tgt_Transmit_DMA(&hi3c, &xferData);
hal_i3c_handle_t hi3c;
uint8_t tx_buf[8] = {0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80};
uint32_t timeout_ms = 5000;

// Transmit data in target mode
hal_status_t status = HAL_I3C_TGT_Transmit(&hi3c, tx_buf, sizeof(tx_buf), timeout_ms);
/* Interrupt and DMA modes: the operation is asynchronous and completion
will be notified to the user via HAL_I3C_TGT_TxCpltCallback */
HAL_I3C_TGT_Transmit_IT(&hi3c, tx_buf, sizeof(tx_buf));
HAL_I3C_TGT_Transmit_DMA(&hi3c, tx_buf, sizeof(tx_buf));

Key changes

  1. HAL2 uses renamed target APIs (HAL_I3C_TGT_Transmit*() instead of HAL_I3C_Tgt_Transmit*()).

  2. In HAL2, the target transmit API takes the buffer directly, instead of using I3C_XferTypeDef.